package com.zheng.hr.rpc.service.impl;

import com.zheng.common.annotation.BaseService;

import com.zheng.hr.dao.model.HrAttendance;
import com.zheng.hr.dao.mapper.HrAttendanceMapper;
import com.zheng.hr.rpc.api.HrAttendanceService;
import com.zheng.common.base.BaseServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * hr_attendance 考勤统计 服务实现类
 * </p>
 *
 * @author likun
 * @since 2018-01-08
 */
@Service
@Transactional(rollbackFor = Exception.class)
@BaseService
public class HrAttendanceServiceImpl extends BaseServiceImpl<HrAttendanceMapper, HrAttendance> implements HrAttendanceService {
    @Autowired
    private HrAttendanceMapper attendanceMapper;

    public List<Map<String, Object>> selectAttendancePage(HrAttendance attendance, String organizationId) {
        String[] organizationIds = null;
        if(StringUtils.isNotBlank(organizationId)){
            organizationIds = organizationId.split(",");
        }
        return attendanceMapper.selectAttendancePage(attendance, organizationIds);
    }

    public Integer selectAttendancePageCount(HrAttendance attendance, String organizationId) {
        String[] organizationIds = null;
        if(StringUtils.isNotBlank(organizationId)){
            organizationIds = organizationId.split(",");
        }
        return attendanceMapper.selectAttendancePageCount(attendance, organizationIds);
    }
}
